#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtWebEngineWidgets>
#include "MW_WebEngineView.h"

#include "EncryptionZ.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pbtnOpenURL_clicked()
{
    QString strUrl = ui->ledtURL->text().trimmed();
    if (strUrl.isEmpty())
    {
        QMessageBox::information(NULL, "请输入URL", "URL为空", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
        return;
    }
    QString strINI = ui->ledtINI->text().trimmed();
    if (strINI.isEmpty())
    {
        QMessageBox::information(NULL, "请输入INI完整路径文件名", "INI路径文件名为空", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
        return;
    }

    FmwWEV.SetURL(strUrl);
    FmwWEV.SetINI(strINI);
    FmwWEV.show();
    FmwWEV.activateWindow();
}

void MainWindow::on_pbtnJiaMi_clicked()
{
    QString strMiWen;
    JiaMi(g_strHashKey, "okmnji79513", &strMiWen);// 明文 密文
    qDebug() << "MiWen : ";
    qDebug() << strMiWen;
}

void MainWindow::on_pbtnJieMi_clicked()
{
    QSettings set(ui->ledtINI->text().trimmed(), QSettings::IniFormat);

    QVariant qvar = set.value(QString("/%1/%2").arg("taobao_login").arg("username"));
    QString strUserName = qvar.toString();
    qDebug() << strUserName;

    QString strMingWen;
    JieMi(g_strHashKey, strUserName, &strMingWen);// 密文 明文
    qDebug() << "MingWen : ";
    qDebug() << strMingWen;
}
